from apps.app import Flask
from apps.config import secure, setting


def register_plugin(cmp_app):
    from apps.models.base import db
    db.init_app(cmp_app)
    with cmp_app.app_context():
        db.create_all()

def create_app():

    cmp_app = Flask(__name__)
    cmp_app.config.from_object(secure)
    cmp_app.config.from_object(setting)

    return cmp_app

app = create_app()

register_plugin(app)

from apps.api import create_blueprint_v1
app.register_blueprint(create_blueprint_v1())